package clients;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import util.HttpRequest;

public class Test01Client {
	public static void main(String[] args) {
		String path = "http://localhost:8888/server/jdkHttpConn";
		String method = "POST";
		int timeout = 10000;
		client(path, method, timeout);
	}
	
	public static void client(String path, String method, int timeout) {
		StringBuilder stringBuilder = new StringBuilder();
		InputStreamReader reader = null;
		InputStream is = null;
		is = HttpRequest.httpUrlConn(path, method, timeout);
		reader = new InputStreamReader(is);
		char[] cs = new char[1024];
        int len = 0;
        try {
			while ((len = reader.read(cs, 0, cs.length)) != -1){
				stringBuilder.append(cs, 0, len);	
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        System.out.println(stringBuilder.toString());
	}
}

